package com.djf.eg.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.djf.eg.entity.SysPermission;
import com.djf.eg.result.Result;
import com.djf.eg.service.PermissionService;
import com.djf.eg.vo.MenuVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;

@RestController
@RequestMapping("/permissions")
public class PermissionController extends DBaseController {
	@Autowired
	PermissionService permissionService;
	
	@GetMapping("")
	public Result getPermissions(@RequestParam int pageNum, @RequestParam int pageSize) {
		Page<SysPermission> result = permissionService.getPermissions(pageNum, pageSize);
		return Result.success(new PageInfo<SysPermission>(result));
	}
	
//	@GetMapping("")
//	public Result getPermissions() {
//		List<MenuVo> result = permissionService.getAllPermissions();
//		return Result.success(result);
//	}	
	
	@GetMapping("/all")
	public Result getAllPermissions() {
		List<MenuVo> result = permissionService.getAllPermissions();
		return Result.success(result);
	}
	
}
